import { AxiosProgressEvent } from 'axios';

import { request } from '@/utils/request/axios';
import { AjaxResult, UploadFileParams } from '#/request';

const VITE_UPLOAD_BASEURL = import.meta.env.VITE_UPLOAD_BASEURL;

/** 上传文件 - axios */
export function uploadApi<T = AjaxResult>(
  url: string = VITE_UPLOAD_BASEURL,
  params?: UploadFileParams,
  onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
) {
  return request.uploadFile<T>(
    {
      url,
      onUploadProgress,
    },
    params,
  );
}
